Skip to content

gh-104231: emit warning on __bytes__ and __str__ when returning strict subclass#108814

Open
sunmy2019 wants to merge 2 commits intopython:mainfrom
sunmy2019:gh-104231
Open

gh-104231: emit warning on __bytes__ and __str__ when returning strict subclass#108814
sunmy2019 wants to merge 2 commits intopython:mainfrom
sunmy2019:gh-104231

Conversation

@sunmy2019
Copy link
Member

@sunmy2019 sunmy2019 commented Sep 2, 2023

Returning strict subclasses at __str__ can cause unexpected behavior, since other parts of the VM have always assumed str(x) to be an instance of str, not its strict subclass. The same applies to the bytes(x).

Hence, we deprecated the ability to return strict subclasses of str/bytes at __str__/__bytes__, respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants